<?php
date_default_timezone_set('PRC');
// 链接数据
$conn = mysqli_connect('localhost', 'root', 'root', 'guanji');
$month = date('Y-m-d');
if ($conn) {
  $data = [];
  $sql = "select * from house where status = 1";
  $result = mysqli_query($conn, $sql);
  $sql1 = "insert into house_statistics(gid,date,count,total_cost) VALUES ";
  while($row = mysqli_fetch_assoc($result))
  {
    $sql1 .= "({$row['goods_id']},'{$month}',{$row['count']},{$row['total_amount']}),";
  }
  if ($sql1 && $result) {
    $sql1 = substr($sql1, 0, strlen($sql1)-1).';';
    mysqli_query($conn, $sql1);
  }
  mysqli_close($conn);
}
